一个form中同时有<input type="file">和<input type="text">,jsp页面中同时得到这两个值

来源:百度知道 编辑:UC知道 时间:2024/09/25 17:19:43
当点击提交后 同时获得表单中txt"表格"的值和file"浏览"的值

分别给他们一个定一个一个属性如:
<input type="file" id="file">
<input type="text" id="text">
就这样了 这样就可以分开了,JSP中对应页面的.do就会进行处理了。大概如这样:String file = (String)thisForm.getFile();
String text = (String)thisForm.gettext(); 当然其中的get方法和thisForm还是要根据你的页面有所不同的。

<input type="file" id="file1">
<input type="text" id="text1">

String strFile=request.getParameter("file1");
String strTxt=request.getParameter("text1");

Parameter可能拼写不对,看下Myeclipse的自动的代码补全

先判断是不是文件上传,做不同处理

那要看你用什么框架或者什么包了。具体没什么好说的

<input type="file">记得+ID+NAME 随便起个,要上传上来认不到

最好分开,文件上传单独一个form